<?php

namespace App\Http\Controllers;

use App\Http\Helpers\Sign;
use App\Http\Services\ApiService;
use App\Http\Services\MsgService;
use App\Jobs\SendNoticeJob;
use Illuminate\Http\Request;

class NoticeController extends Controller
{
    /**
     *管理员回复用户
     * @author=> lican<364548233@qq.com>
     */
    public function replyToUser(Request $request){
        $data = file_get_contents("php://input"); //获取aisee通知的参数
        $data = json_decode($data, true);
        Sign::writeLog("Aisee管理员回复通知：", $data, 'aisee');
        $schoolCode = explode('|', $data['eventContent']['userId'])[1];
        $cardNumber = Sign::pregCardNumber($data);
        $redirectUrl = DOMAIN . "/mobile/login";
        $customs = "[\"点击查看回复的内容\", \"{$redirectUrl}\"]";
        $params = [
            'card_number' => [$cardNumber],
            'title' => '管理员回复',
            'content' => $data['eventContent']['replyContent'],
            'sender' => 'Aisee',
            'customs' => $customs
        ];

        dispatch(new SendNoticeJob($schoolCode, $params));
        return MsgService::getMsg(0);
    }

}
